﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GWModflow.FileLayers
{
    public class PWell : Package
    {

        public PWell()
        {
            this._fileType = FileType.WEL;

            this.Nunit = 41;

            this.Fname = "solution.wel";
        }
        
        int _MXACTW;

        /// <summary>
        /// 最大单层循环中活动井的个数
        /// </summary>
        public int MXACTW
        {
            get { return _MXACTW; }
            set { _MXACTW = value; }
        }

        int _IWELCB=101;

        /// <summary>
        /// 标志位
        /// </summary>
        public int IWELCB
        {
            get { return _IWELCB; }
            set { _IWELCB = value; }
        }


        List<SPWell> _stressPeriodWell = new List<SPWell>();
        public List<SPWell> StressPeriodWell
        {
            get { return _stressPeriodWell; }

        }
        public override void WriteFile(string path)
        {
            string content = "# HuanAnKeJi WEL File" + "\r\n";
            content += this._MXACTW.ToString() + "  " + this._IWELCB.ToString() + "\r\n";
            string str = "";
            foreach (SPWell sp in StressPeriodWell)
            {
                str += sp.ITMP + "  " + sp.NP + "\r\n";
                if (sp.ITMP >= 0)
                {
                    string str1 = "";
                    for (int i = 0; i < sp.WellData.Count; i++)
                    {
                        str1 += string.Format("{0,10}", sp.WellData[i].Layer) + " " + string.Format("{0,10}", sp.WellData[i].Row) + " " + string.Format("{0,10}", sp.WellData[i].Column) + " " +
                                string.Format("{0,10}", sp.WellData[i].Value) + "\r\n";// +string.Format("{0,10}", sp.WellData[i].Value2) + string.Format("{0,10}", sp.WellData[i].Value3) + "\r\n";
                    }
                    str += str1;
                }
            }
            content += str;
            string fname = path + this.Fname;
            FXnaInfrastructure.FileHelper.WriteFile(fname, content);
        }
    }
}
